package com.uaroadshow.finale.dao;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.uaroadshow.entity.user.User;
import com.uaroadshow.entity.user.UserInfo;
import com.uaroadshow.entity.user.WechatAccount;

/**
 * 
 * @author mohanlan
 *
 */
@Dao("hibernate")
public interface UserDao {
    
    /**
     * load user by unionid
     * 
     * @param unionid
     * @return
     */
    @Query("FROM User WHERE unionid = :unionid AND disabled = false")
    public User loadUser(@Variable("unionid") String unionid);

    /**
     * 
     * @param unionid
     * @return
     */
    @Query("FROM User WHERE unionid = :unionid AND disabled = false")
    public User getUserByUnionid(@Variable("unionid") String unionid);
    
    /**
     * load wechatAccount by unionid
     * 
     * @param unionid
     * @return
     */
    @Query("FROM WechatAccount WHERE unionid = :unionid")
    public WechatAccount loadAccount(@Variable("unionid") String unionid);
    
    /**
     * @param user
     * @return
     */
    @Query("FROM UserInfo WHERE disabled = false AND user = :user")
    public UserInfo getUserInfo(@Variable("user") User user);
}
